import { InvitorInfoITF, SystemConfigITF, UserITF, WeChatUserInfoITF } from '@INTERFACES/user'
import { Action } from 'redux'

export interface AuthLoginParamsPayLoad {
  encrypted_data?: string,
  iv?: string,
  code?: string,
  PhoneNumber?: string,
  ActionTokenId?: string,
  AuthCode?: string,
  AcquireChannel?: string,
  Invitor?: InvitorInfoITF,
  double?: boolean,
}

export interface AuthLoginPayLoad {
  payload: AuthLoginParamsPayLoad,
  callback: () => void,
  disabledBack: boolean,
  webCallback?: () => void
}

export interface AuthRequestAuthCodePayLoad {
  PhoneNumber: string
}

export interface AuthVisitorLoginPayLoad {
  ClientKey: string,
  ExternalId: string,
}

export interface AuthWeChatLoginPayLoad {
  UserInfo: WeChatUserInfoITF,
}

export interface AuthActionITF extends Action {
  payload?: AuthLoginPayLoad | AuthRequestAuthCodePayLoad |
    AuthVisitorLoginPayLoad | WeChatUserInfoITF
  disableLogin?: boolean,
  visitorLoginSuccess?: (userInfo: UserITF) => void,
  isConnected?: boolean,
  params?: InvitorInfoITF
}

export interface AuthLoginSuccessActionITF extends Action {
  loginSuccess?: () => void
}

export interface AuthStateITF {
  ActionTokenId: string,
  user: UserITF | null,
  isDisabledConsultation: boolean,
  isConnected: boolean,
  lastSetLoginInfoTime?: number,
  loginSuccess?: () => void,
  loadingSystemConfig: boolean,
  systemConfig: SystemConfigITF | null
}

export interface WebLoginFunc {
  showLogin: () => void
}
